<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<script>
	var isGuest = ${EPG_USER_SESSION.isGuest};
	var personUrl = "${personUrl}";
</script>
<div id="boxNotOnLine" class="navbar-fixed-top" style="display:none;text-align:center;line-height:5em;left:15%;top:40%; width: 70%;height:5em;background-color: black;color:white;border-radius:1em;font-size:1.5em;z-index:99999999;opacity:0.6;">未检测到机顶盒在线！</div>
<div id="tip_text" class="alert alert-success navbar-fixed-top" style="display:none;text-align:center"  role="alert">
</div>
<div id="toast" style="display: none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <i class="weui_icon_toast"></i>
        <p id="toast_title" class="weui_toast_content"></p>
    </div>
</div>
<div id="fail" style="display: none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <i class="weui_icon_clear"></i>
        <p id="fail_title" class="weui_toast_content"></p>
    </div>
</div>
<div id="loadingToast" class="weui_loading_toast" style="display: none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <div class="weui_loading">
            <div class="weui_loading_leaf weui_loading_leaf_0"></div>
            <div class="weui_loading_leaf weui_loading_leaf_1"></div>
            <div class="weui_loading_leaf weui_loading_leaf_2"></div>
            <div class="weui_loading_leaf weui_loading_leaf_3"></div>
            <div class="weui_loading_leaf weui_loading_leaf_4"></div>
            <div class="weui_loading_leaf weui_loading_leaf_5"></div>
            <div class="weui_loading_leaf weui_loading_leaf_6"></div>
            <div class="weui_loading_leaf weui_loading_leaf_7"></div>
            <div class="weui_loading_leaf weui_loading_leaf_8"></div>
            <div class="weui_loading_leaf weui_loading_leaf_9"></div>
            <div class="weui_loading_leaf weui_loading_leaf_10"></div>
            <div class="weui_loading_leaf weui_loading_leaf_11"></div>
        </div>
        <p id="loading_title" class="weui_toast_content"></p>
    </div>
</div>

<script>
window.onload = function() {
	if(typeof init == "function") {
		init();
	}
	var width = document.body.clientWidth;
	var widthNum = removePX(div.style.width);
	div.style.left = (width - widthNum-8) + "px";
	//remoteCtrlCheck();
	//remoteShow();
}
</script>
<div id="rc_flag_img" style="position:fixed;width:32px;height:65px;left:340px;top:200px;z-index:99999">
	<a href="javascript:remoteShow();">
		<img src="${_contextPath}/sites/weixin/images/rc_flag.png" 
			width="40" height="40"/>
	</a>
</div>
<div id="remoteCtrl" class="" style="position:fixed;left:0px;top:0px;z-index:99999">	

</div>
<script>
var div = document.getElementById('rc_flag_img');
div.addEventListener('touchmove', function(event) {
	event.preventDefault();//阻止其他事件
	// 如果这个元素的位置内只有一个手指的话
	if (event.targetTouches.length == 1) {
	 	var touch = event.targetTouches[0]; // 把元素放在手指所在的位置
	 	div.style.left = getXY(touch.pageX,"left") + 'px';
	  	div.style.top = getXY(touch.pageY,"top") + 'px';
	  	div.style.background = "";
	}
}, false);
function getXY(value,direction){
	  var max = document.body.clientWidth;
	  var width = div.style.width;
	  var widthNum = removePX(width);
	  var value = parseInt(value)-widthNum/2;
	  if(direction == "top"){
		max = $(window).height();
		value = value - document.body.scrollTop;
	  }
	  if(value > 0){
		  if(value > (max-widthNum)){
			  //alert(value+","+max+","+widthNum);
			  return parseInt(max)-widthNum;
		  }else{
			  return value;
		  }
	  }else{
		  return 0;
	  }
}
div.addEventListener('touchend', function(event) {
	  //event.preventDefault();//阻止其他事件
	  if (event.targetTouches.length == 0) {
		 	var touch = event.targetTouches[0]; // 把元素放在手指所在的位置
		 	var left = div.style.left;
		 	var top = div.style.top;
		 	var leftNum = removePX(left);
		 	var topNum = removePX(top);
		 	var height = $(window).height();
		 	var width = document.body.clientWidth;
		 	var widthDiv = div.style.width;
			var widthNum = removePX(widthDiv);
		 	var rightNum = width - leftNum - widthNum;
		 	var downNum = height - topNum - widthNum;
		 	
		 	var directionX = 1;
		 	var minX = leftNum;
		 	if(rightNum < leftNum){
		 		minX = rightNum;
		 		directionX = 2;
		 	}
		 	var directionY = 1;
		 	var minY = topNum;
		 	if(downNum <topNum){
		 		minY = downNum;
		 		directionY = 2;
		 	}
		 	
		 	if(minX <= minY){
		 		if(directionX == 1){
		 			div.style.left = "0px";
			 		div.style.top = topNum + "px";
		 		}else{
		 			div.style.left = (width - widthNum-8) + "px";
			 		div.style.top = topNum + "px";
		 		}
		 	}else{
		 		if(directionY == 1){
		 			div.style.top = "0px";
			 		div.style.left = leftNum + "px";
		 		}else{
		 			div.style.top = (height - widthNum-8) + "px";
			 		div.style.left = leftNum + "px";
		 		}
		 	}
	  	}
},false);
</script>
